package cn.js.controller;

import cn.js.dto.User;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * Description:
 *
 * @Author Js
 * @Create 2024-11-23 22:18
 * @Version 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {


    @PostMapping("/get_user_list")
    public User getUserList(@RequestBody User user) {
        return user;
    }


    @GetMapping("/get_data")
    public Object getData() {
        return 100L;
    }

    @GetMapping("/get_arr")
    public String getArr(@RequestParam("arr") String[] arr) {
        return "user ok!" + Arrays.toString(arr);
    }

    @PostMapping("/get_user")
    public String getUser(@RequestBody User user) {
        return "user ok! " + user.toString();
    }

    @GetMapping("/{name}")
    public String getName(@PathVariable("name") String name) {
        return "user ok! name=" + name;
    }

    @GetMapping("/get_info")
    public String getInfo(Long id) {
        return "user ok! id=" + id;
    }
    @GetMapping("/user/{id}")
    public User getById(@PathVariable Long id){
        return new User(id,"张三:" + id, "我是张三",null);
    }
}
